package com.stop.action;

import java.lang.reflect.Type;

import org.apache.struts2.ServletActionContext;

import com.google.gson.reflect.TypeToken;
import com.stop.bean.JsonBean;
import com.stop.bean.User;
import com.stop.utils.Common;

@SuppressWarnings("serial")
public class JsonTestAction extends BasicAction {

	public String execute() throws Exception {
		setOut(ServletActionContext.getResponse().getWriter());

		JsonBean<User> json = new JsonBean<User>();
		User user = new User();
		user.setName("admin");
		user.setPassword("admin");
		json.setResultCode(1001);
		json.setResult(user);
		Type type = new TypeToken<JsonBean<User>>() {
		}.getType();
		getOut().write(Common.<JsonBean<User>> packageJson(json, type));
		getOut().flush();
		getOut().close();
		return null;
	}

}
